/**
 * Created by PengWei on 2018/7/26.
 */
namespace mengdao {
    export class BaseLifecycleObj implements IDispose {
        /** 生命周期 */
        protected _lifecycle: Lifecycle;

        public constructor() {
            this._lifecycle = new Lifecycle();
        }

        /**
         * 激活
         */
        public active(): void {
            if (!this._lifecycle.hasInitialized) {
                this.initialize();
            }

            this._lifecycle.state = LifecycleState.ACTIVE;
        }

        public sleep(): void {
            this._lifecycle.state = LifecycleState.SLEEP;
        }

        public initialize(): void {
            this._lifecycle.state = LifecycleState.INITIALIZED;
        }

        public dispose(): void {

        }
    }
}